package com.javaweb.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.javaweb.admin.entity.*;
import com.javaweb.admin.query.ReturnQuery;
import com.javaweb.admin.vo.returnorder.StoreNameVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ReturnOrderMapper extends BaseMapper<ReturnOrder> {
    IPage<SaleOrder> getReturnSaleOrderList(IPage<SaleOrder> page, @Param("req") ReturnQuery req);

    @Select("select t1.*,t2.realreason,t2.remark,t2.opertype from vw_return_saleorderdetail t1 left join sys_sosaleorder_b t2 on t1.csaleorderbid=t2.csaleorderbid  where t1.csaleorderid=#{csaleorderid}")
    List<SaleOrderDetail> gerSaleOrderDetail(String csaleorderid);

    IPage<ReturnOrder> getReturnOrderList(IPage<ReturnOrder> page, @Param("req") ReturnQuery req);

    IPage<ReturnOrderInvoiceDetail> getSecondSaleInvoiceList(IPage<ReturnOrderInvoiceDetail> page, @Param("req") ReturnQuery req);

    IPage<ReturnOrderDetail> getSecondSaleList(IPage<ReturnOrderDetail> page, @Param("req") ReturnQuery req);

    IPage<ReturnOrderDetail> getSecondSaleStockList(IPage<ReturnOrderDetail> page, @Param("req") ReturnQuery req);

    IPage<ReturnOrderDetail> getSecondSaleGroupStockList(IPage<ReturnOrderDetail> page, @Param("req") ReturnQuery req);

    @Select("select t1.*,t2.realreason,t2.remark,t2.opertype from vw_returnorder_detail t1 left join sys_sosaleorder_return_b t2 on t1.cgeneralbid=t2.cgeneralbid  where t1.cgeneralhid=#{csaleorderid}")
    List<ReturnOrderDetail> gerOrderDetail(String cgeneralhid);

    @Select("select * from vw_return_invoice where csaleorderid=#{csaleorderid}")
    List<ReturnOrderInvoiceDetail> gerOrderInvoiceDetail(String csaleorderid);

    @Select("select * from vw_return_check_invoice where rkbillcode=#{rkbillcode} order by vlotno")
    List<ReturnOrderCheck> gerOrderCheckDetail(String rkbillcode);

    //销售订单中查询退货入库信息
    @Select("select * from vw_return_check_invoice where csaleorderid=#{csaleorderid} order by vlotno")
    List<ReturnOrderCheck> gerSaleOrderCheckDetail(String csaleorderid);

    @Select("select * from vw_secondsale_invoice_b where cgeneralbid=#{csaleorderbid} and checknum>0")
    List<ReturnOrderInvoiceDetail> getResaleList(String csaleorderbid);

    @Select("select * from vw_instock_checklist where csaleinvoicebid=#{csaleinvoicebid}")
    List<ReturnOrderInvoiceDetail> getInstockCheckList(String csaleinvoicebid);

    @Select("select storename,pk_org from vm_stordoc  where pk_org = '0001V1100000001HF0FV'")
    List<StoreNameVo> getStoreNameList();

    @Select("select distinct deot2.name from sine_ods.dbo.ods_nc_org_dept t1 inner join sine_ods.dbo.ods_nc_org_dept as  deot2 on t1.def10 = deot2.pk_dept")
    List<String> getSSBKList();
}
